package com.itlaoqi.rabbitmq.workqueue;

import com.google.gson.Gson;
import com.itlaoqi.rabbitmq.utils.RabbitConstant;
import com.itlaoqi.rabbitmq.utils.RabbitUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class OrderSystem {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(RabbitConstant.QUEUE_SMS,false,false,false,null);
        for (int i = 101; i <= 200; i++) {
            SMS sms = new SMS("乘客" + i,"139000000" + i,"预定成功");
            String jsonSMS = new Gson().toJson(sms);
            channel.basicPublish("",RabbitConstant.QUEUE_SMS,null,jsonSMS.getBytes());
        }
        channel.close();
        connection.close();
        System.out.printf("发送数据成功");
    }
}






















